
    /**
     * messageBox.java
     * Dimiourgi ena JFrame sto opio periehete to JComboBox
     * apo to opio ginete i epilogi tou hromatos ton Pieces pou tha ehi o player1.
     */

package GUI;

import gameStructure.playersChoice;
import gameStructure.StateHolder;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.event.*;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

public class messageBox extends JFrame{

    public messageBox() {
    final String [] labels = { "Random","White","Black"};
    final DefaultComboBoxModel model = new DefaultComboBoxModel(labels);

    JFrame frame = new JFrame("Player's Choice.");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container contentPane = frame.getContentPane();


    final JComboBox comboBox2 = new JComboBox(model);
    comboBox2.setMaximumRowCount(4);
    comboBox2.setEditable(true);
    comboBox2.setAlignmentX(Component.LEFT_ALIGNMENT);
    
    contentPane.add(comboBox2, BorderLayout.CENTER);
    final JTextField text = new JTextField(10);
    contentPane.add(text , BorderLayout.PAGE_START);
    final JTextField text2 = new JTextField(10);
    contentPane.add(text2 , BorderLayout.AFTER_LAST_LINE);
    JOptionPane.showMessageDialog(this,"When selecting the players color from the comboBox be warned that its for the Player1!","Info:",JOptionPane.INFORMATION_MESSAGE);
    text.setText("*Name of Player1*");
    text2.setText("*Name of Player2*");
    
    JButton playButton = new JButton("Play");
    contentPane.add(playButton, BorderLayout.EAST);
    ActionListener playActionListener = new ActionListener(){
      public void actionPerformed(ActionEvent actionEvent) {
          System.out.println("TEXT IS: "+text.getText());
          System.out.println("COMBO IS: "+comboBox2.getSelectedItem());
          String [] names = {text.getText(), text2.getText()};
          playersChoice choi = new playersChoice(text.getText().charAt(0), names );
          CreateChessBoard toChessBoard= new CreateChessBoard();
          StateHolder pi = new StateHolder();
          toChessBoard.setPieces(pi.Board); // kali tin CreateChessBoard tou GUI, AFOU ehi prota dimiourgisi tin Board apo tin anexartiti tou GUI StateHolder.
      }
    };
    playButton.addActionListener(playActionListener);
    
    JButton exitButton = new JButton("Exit");
    contentPane.add(exitButton, BorderLayout.WEST);
    ActionListener exitActionListener = new ActionListener() {
      public void actionPerformed(ActionEvent actionEvent) {
        System.exit(0);
      }
    };
    exitButton.addActionListener(exitActionListener);

    frame.setSize(300, 200);
    frame.setVisible(true);
    }
}